#include "Diamond.h"

DynamicTrimesh* createDiamond(dWorldID &world, dSpaceID &space)
{
	std::vector<Vertex> vertices;
	std::vector<GLuint> indices;

	Vertex firstVert;
	firstVert.position = cml::vector3f(-0.5f, 0.0f, -0.5f);
	firstVert.normal = cml::vector3f(-1.0f, 0.0f, -1.0f).normalize(); //Placeholder
	vertices.push_back(firstVert);

	Vertex secondVert;
	secondVert.position = cml::vector3f(0.5f, 0.0f, -0.5f);
	secondVert.normal = cml::vector3f(1.0f, 0.0f, -1.0f).normalize(); //Placeholder
	vertices.push_back(secondVert);

	Vertex thirdVert;
	thirdVert.position = cml::vector3f(0.5f, 0.0f, 0.5f);
	thirdVert.normal = cml::vector3f(1.0f, 0.0f, 1.0f).normalize(); //Placeholder
	vertices.push_back(thirdVert);

	Vertex fourthVert;
	fourthVert.position = cml::vector3f(-0.5f, 0.0f, 0.5f);
	fourthVert.normal = cml::vector3f(-1.0f, 0.0f, 1.0f).normalize(); //Placeholder
	vertices.push_back(fourthVert);

	Vertex topVert;
	topVert.position  = cml::vector3f(0.0f, 0.5f, 0.0f);
	topVert.normal = cml::vector3f(0.0f, 1.0f, 0.0f).normalize(); //Placeholder
	vertices.push_back(topVert);

	Vertex bottomVert;
	bottomVert.position  = cml::vector3f(0.0f, -0.5f, 0.0f);
	bottomVert.normal = cml::vector3f(0.0f, -1.0f, 0.0f).normalize(); //Placeholder
	vertices.push_back(bottomVert);

	//Top piece
	indices.push_back(4); indices.push_back(1); indices.push_back(0);
	indices.push_back(4); indices.push_back(0); indices.push_back(3);
	indices.push_back(4); indices.push_back(3); indices.push_back(2);
	indices.push_back(4); indices.push_back(2); indices.push_back(1);

	//Bottom
	indices.push_back(5); indices.push_back(0); indices.push_back(1);
	indices.push_back(5); indices.push_back(3); indices.push_back(0);
	indices.push_back(5); indices.push_back(2); indices.push_back(3);
	indices.push_back(5); indices.push_back(1); indices.push_back(2);

	return new DynamicTrimesh(world, space, vertices, indices);
}
